<template>
  <page-header-wrapper :title="false">
    <a-card title="已隐藏的业务">
      <div class="table-page-search-wrapper">
        <a-form-model :model="queryParam" layout="inline">
          <a-row :gutter="48">
            <a-col :md="6" :sm="24">
              <a-form-item label="合同编号">
                <a-input v-model="queryParam['filter[contract_no]']" placeholder="输入合同编号" />
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="24">
              <a-form-model-item label="业务编号">
                <a-input v-model="queryParam['filter[business_no]']" placeholder="输入业务编号" />
              </a-form-model-item>
            </a-col>
            <a-col :md="!advanced && 8 || 24" :sm="24">
              <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
                <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
                <a-button style="margin-left: 8px" @click="resetForm">重置</a-button>
              </span>
            </a-col>
          </a-row>
        </a-form-model>
      </div>
      <div class="table-operator">
        <s-table
          bordered
          ref="table"
          size="middle"
          :row-key="(record) => record.cb_id"
          :columns="businessColumns"
          :data="businessData"
        >
          <template slot="action" slot-scope="text,record">
            <a-button type="danger" size="small" @click="show(record.record.cb_id)">恢复</a-button>
          </template>
        </s-table>
      </div>
    </a-card>
  </page-header-wrapper>
</template>

<script>
  import { STable } from '@/components'
  import businessColumns from '@/columns/business'
  import { getHideList, hideBusiness } from '@/api/business'
  export default {
    components: {
      STable
    },
    name: 'BusinessHide',
    data () {
      return {
        advanced: true,
        queryParam: {},
        businessColumns: businessColumns.tmColumns1,
        businessData: parameters => {
          return getHideList(Object.assign(parameters, this.queryParam)).then(res => {
            return res.result
          })
        }
      }
    },
    methods: {
      resetForm () {
        this.queryParam = {}
        this.$refs.table.refresh(true)
      },
      show (id) {
        const app = this
        hideBusiness(id).then(res => {
          if (res.status === 0) {
            app.$refs.table.refresh()
          } else {
            app.$warning({
              title: res.msg
            })
          }
        })
      }
    }
  }
</script>

<style scoped>

</style>
